package score;

import java.io.BufferedReader;
import java.io.IOException;

import myExceptions.MyFileException;

public class Score {
	
	private String userName;
	private int diffic;
	private double score;
	
	/**
	 * Crea un nuevo objeto puntaje 
	 * @param user  nombre del jugador
	 * @param dificul  dificultad
	 * @param puntaje  puntaje de juego
	 * @see Scorelist
	 */
	public Score(String user, int dificul, double puntaje) {
		userName = user;
		diffic = dificul;
		score = puntaje;
		
	}
	/**
	 * Crea un puntaje desde un archivo para almacenarlo en la lista de puntajes 
	 * @param buf
	 * @throws MyFileException
	 */
	public Score(BufferedReader buf) throws MyFileException {
		String line;
		userName = readLine(buf );
		line = readLine(buf );
		diffic =  Integer.parseInt(line);
		line = readLine(buf );
		score =  Double.parseDouble(line);
	}
	
	public String readLine (BufferedReader buf) throws MyFileException {
		
		String line = null;

		try {
			line = buf.readLine();
		} catch (IOException e) {
			throw new MyFileException("Corrupt file");
		}
		
		return line;
	}
	
	public int getDiffic() {
		return diffic;
	}
	public void setDiffic(int diffic) {
		this.diffic = diffic;
	}
	public double getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
}
